<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
	<script>var ctx="${ctx}";</script>
	<head>
	    <meta charset="utf-8">
	    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	    <title>Mr Cargo管理平台</title>
	    <meta name="keywords" content="体验,友好,高级管理台,易用,高性能,高扩展性,bootstrap框架,响应式后台">
	    <meta name="description" content="这是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
	    <meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
		<meta http-equiv="expires" content="Wed, 26 Feb 209908:21:57 GMT"> 
	    <!--[if lt IE 8]>
	    <meta http-equiv="refresh" content="0;ie.html" />
	    <![endif]-->
	    <link rel="shortcut icon" href="favicon.ico"> 
		<link href="${ctx}/static/css/bootstrap.min.css?v=${static_version}" rel="stylesheet">
		<link href="${ctx}/static/css/font-awesome.min.css?v=4.4.0?v=${static_version}" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/footable/footable.core.css?v=${static_version}" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/summernote/summernote.css?v=${static_version}" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/summernote/summernote-bs3.css?v=${static_version}" rel="stylesheet">
		<link href="${ctx}/static/plugins/laypage/laypage.css?v=${static_version}"  rel="stylesheet">
		<link href="${ctx}/static/css/plugins/chosen/chosen.css?v=${static_version}" rel="stylesheet">
		<link href="${ctx}/static/css/animate.min.css?v=${static_version}" rel="stylesheet">
		<link href="${ctx}/static/js/plugins/layer/laydate/laydate.css?v=${static_version}" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/webuploader/webuploader.css?v=${static_version}" rel="stylesheet">
		<link href="${ctx}/static/css/style.min.css?v=4.0.0" rel="stylesheet">
	    
	</head>
	<body class="gray-bg" id="sysScheduleJob_body">
    	<div class="ibox float-e-margins">
    		<div class="ibox-content">
                <form class="form-group" id="sysScheduleJob_table_form" >
                	<input type="hidden" name="orderBy" value="create_date desc">
                	<button id="sysScheduleJob_table_search" type="button" class="btn btn-outline btn-block btn-primary" style="display:none;">查询</button>
                	<div class="row">
                        <div class="col-md-2 col-sm-2"><a  onclick="clickInsertGet()" class="btn btn-block btn-outline btn-primary">添加</a></div>
                    </div>
                </form>
				<table id="sysScheduleJob_table" data-action="${ctx}/scheduleJob/find" data-datatable="true"  class="footable table table-stripped toggle-arrow-tiny">
				  	<thead>
					  	<tr>
							<th  data-sort-ignore="true" data-title ="jobType" data-toggle="true">任务类型</th>
							<th  data-sort-ignore="true" data-title ="createTime" data-hide="phone,tablet" data-type="datetime">创建时间</th>
							<th  data-sort-ignore="true" data-title ="jobGroup" >任务组</th>
							<th  data-sort-ignore="true" data-title ="description" >描述</th>
							<th  data-sort-ignore="true" data-title ="jobStatus" >状态</th>
							<th  data-sort-ignore="true" data-title ="updateTime" data-hide="phone,tablet" data-type="datetime">更新时间</th>
							<th  data-sort-ignore="true" data-title ="jobName" >任务名称</th>
							<th  data-sort-ignore="true" data-title ="cronExpression" >任务表达式</th>
							<th  data-sort-ignore="true" data-title ="methodName" >任务方法</th>
							<th  data-sort-ignore="true" data-title ="beanClass" >任务类名</th>
							<th  data-sort-ignore="true" data-title ="springId" >SpringId</th>
						  	<th data-crud="true" data-title='{"uid":"id"}' data-hide="phone">操作
			      			  <div style="display: none;" class="center hidden-phone">
			      			  	<button onclick="stop(this)"  data-id=":uid" type="button" class="btn btn-primary btn-xs">暂停</button>
			      			  	<button onclick="resume(this)"  data-id=":uid" type="button" class="btn btn-primary btn-xs">恢复</button>
			      			  	<button onclick="del(this)"  data-id=":uid" type="button" class="btn btn-primary btn-xs">删除</button>
			      			  	<button onclick="startNow(this);"  data-id=":uid" type="button" class="btn btn-primary btn-xs">立即运行一次</button>
			      			  	<button onclick="clickUpdateGet(this)"  data-id=":uid" type="button" class="btn btn-primary btn-xs">更新</button>
							  </div> 
		      		      	</th>
					  	</tr>
				  	</thead>
				  	<tbody>
				  	</tbody>
			  	</table>
			</div>
		</div>
		
	<script src="${ctx}/static/js/jquery.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/bootstrap.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/footable/footable.all.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/validate/jquery.validate.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/validate/messages_zh.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/webuploader/webuploader.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/summernote/summernote.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/summernote/summernote-zh-CN.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/chosen/chosen.jquery.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/layer/laydate/laydate.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/iCheck/icheck.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/plugins/laypage/laypage.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/switchery/switchery.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/eModal.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/iCheck/icheck.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/cookie.js?v=?v=${static_version}""></script>
	<script src="${ctx}/static/common/custom-table.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/content.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/common/common.js?v=${static_version}"></script>
	
	<script>
		$(document).ready(function() {
			init_page_table();
		});
		
		var clickInsertGet=function(){
			eModal.ajax({
	   	        url: "${ctx}/scheduleJob/insertGet",
	   	        title:'添加定时任务',
	   	        loading:true,
	   	        subtitle: '',
	   	        buttons: [
	   	            {text: '保存', style: 'info',   close: false, click:function(){
	   	            	if (!jQuery.checkall(true)) return;
	   	 		    	$.ajax({  
	   	 					url:'${ctx}/scheduleJob/add',  
	   	 					data:{
								jobType:$("#jobType").val(),							
								jobGroup:$("#jobGroup").val(),							
								tempId:$("#tempId").val(),			
								description:$("#description").val(),							
								jobName:$("#jobName").val(),							
								cronExpression:$("#cronExpression").val(),							
								methodName:$("#methodName").val(),							
								beanClass:$("#beanClass").val(),							
								springId:$("#springId").val(),
								token:$("#token").val()
							},   
							type: 'POST',
	   	 					dataType:'json',  
	   	 					success:function(response){
	   	 						if(response.code==0){
	   	 							eModal.close();
	   	 							$("#sysScheduleJob_table_search").click();
	   	 						}else{
	   	 						    $.confirm({cancelButton:"关   闭",title:'提示',text:"保存数据错误!"});
	   	 						}
	   	 					}  
	   	 			    }); 
	   	            }},{text: '取消', style: 'danger', close: false, click:function(){
	   	            	eModal.close();
	   	            }}
	   	        ],
	   	    });
			return false;
		}
		
		var clickUpdateGet=function(me){
			eModal.ajax({
	   	        url: "${ctx}/scheduleJob/updateGet?id="+$(me).data("id"),
	   	        title:'修改定时任务',
	   	        loading:true,
	   	        subtitle: '',
	   	        buttons: [
	   	            {text: '保存', style: 'info',   close: false, click:function(){
	   	            	if (!jQuery.checkall(true)) return;
	   	 		    	$.ajax({  
	   	 					url:'${ctx}/scheduleJob/update',  
	   	 					data:{
								cron:$("#cronExpression").val(),							
								id:$("#id").val()
							},   
							type: 'POST',
	   	 					dataType:'json',  
	   	 					success:function(response){
	   	 						if(response.code==0){
	   	 							eModal.close();
	   	 							$("#sysScheduleJob_table_search").click();
	   	 						}else{
	   	 						    $.confirm({cancelButton: "关   闭",title: '提示',text:"更新数据错误!"});
	   	 						}
	   	 					}  
	   	 			    }); 
	   	            }},{text: '取消', style: 'danger', close: false, click:function(){
	   	            	eModal.close();
	   	            }}
	   	        ],
	   	    });
			return false;
		}
		
		$(function(){
			jQuery.searchFormInit();
		});
		
		//暂停
		function stop(me){
			$.ajax({  
				url:'${ctx}/scheduleJob/stop',  
				data:{
					id:$(me).data("id")
				},   
				type: 'POST',
				dataType:'json',  
				success:function(response){
					if(response.code==0){
						eModal.close();
						$("#sysScheduleJob_table_search").click();
					}else{
					    $.confirm({cancelButton: "关   闭",title: '提示',text:"停止任务错误!"});
					}
				}  
		    });
			return false;
		}

		//恢复
		function resume(me){
			$.ajax({  
				url:'${ctx}/scheduleJob/resume',  
				data:{
					id:$(me).data("id")
				},   
				type: 'POST',
				dataType:'json',  
				success:function(response){
					if(response.code==0){
						eModal.close();
						$("#sysScheduleJob_table_search").click();
					}else{
					    $.confirm({cancelButton: "关   闭",title: '提示',text:"恢复数据错误!"});
					}
				}  
			});
			return false;
		}

		//删除
		function del(me){
			$.ajax({  
				url:'${ctx}/scheduleJob/delete',  
				data:{
					id:$(me).data("id")
				},   
				type: 'POST',
				dataType:'json',  
				success:function(response){
					if(response.code==0){
						eModal.close();
						$("#sysScheduleJob_table_search").click();
					}else{
					    $.confirm({cancelButton: "关   闭",title: '提示',text:"删除数据错误!"});
					}
				}  
			});
			return false;
		}

		//立即运行一次
		function startNow(me){
			$.ajax({  
				url:'${ctx}/scheduleJob/startNow',  
				data:{
					id:$(me).data("id")
				},   
				type: 'POST',
				dataType:'json',  
				success:function(response){
					if(response.code==0){
						eModal.close();
						$("#sysScheduleJob_table_search").click();
					}else{
					    $.confirm({cancelButton: "关   闭",title: '提示',text:"运行任务错误!"});
					}
				}  
			});
			return false;
		}
		
	</script>
	</body>
</html>